package com.resource.studentmanage.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.resource.studentmanage.entity.TStudentInformationEntity;
import com.resource.studentmanage.mapper.TStudentInformationDao;
import com.resource.studentmanage.service.TStudentInformationService;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.Set;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.resource.common.utils.PageUtils;
import com.resource.common.utils.Query;


@Service
public class TStudentInformationServiceImpl extends ServiceImpl<TStudentInformationDao, TStudentInformationEntity> implements TStudentInformationService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        int size = params.size();
        IPage<TStudentInformationEntity> page=new Page<>();
        if(size==4){
            String keys="";
            String param="";
            Set<String> strings = params.keySet();
            for (String key : strings) {
                keys=key;
                param=params.get(keys).toString();
            }
            page = this.page(
                    new Query<TStudentInformationEntity>().getPage(params),
                    new QueryWrapper<TStudentInformationEntity>().eq(keys,param)
            );
            return new PageUtils(page);
        }
        page = this.page(
                new Query<TStudentInformationEntity>().getPage(params),
                new QueryWrapper<TStudentInformationEntity>()
        );

        return new PageUtils(page);
    }

}